<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<base href="http://localhost:8080/ssm/">
<link href="static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
<script src="static/bootstrap/js/jquery.js"></script>
<script src="static/bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
	<h1>ajax取json数据</h1>
	<button>测试ajax</button>
</body>
<script>
$(function (){
	$("button").eq(0).click(function(){
		$.ajax({
			url:"http://localhost:8080/ssm/heros",
			data:{"page":4},
			type:"get",
			success:function(ret){
				console.log(ret);
				if(ret.success){
					showData(ret);
				}else{
					alert(ret.message);
					//在spring-web做异常处理才可实现
				}
			}
		});
	});
	//显示json数据
	function showData(ret){
		var list=ret.data.Users;
		$.each(list,function(index,item){
			console.log(item.username);
		});
	}
});
</script>
</html>